<?php

//deleteThemes();
//scanThemes();


//List Themes

echo '<h2>Select a Theme</h2>';

//Current Theme

$currentTheme = mysql_query("SELECT name FROM `themes` WHERE active = '1'");

while($theme = mysql_fetch_array($currentTheme)){

echo "<p>" . $theme['name'] . " ";

}

$listThemes = mysql_query("SELECT id,name FROM `themes` WHERE active = '0'");
while($theme = mysql_fetch_array($listThemes)){

echo "<a href='admin.php?action=theme&applytheme=". $theme['id'] . "'>Apply " .$theme['name'] . "</a><br />";

}



if($_GET['applytheme']){

$themeId = secure($_GET['applytheme']);

$fixOldTheme = mysql_query("UPDATE `themes` SET active = '0' WHERE active = '1'")
or die(mysql_error());  

if(!$fixOldTheme) echo 'bugger';

$specifyTheme = mysql_query("UPDATE `themes` SET active = '1' WHERE id='$themeId'")
or die(mysql_error());  



}

?>